package com.yhgarden.bbs.controller.system;

import com.yhgarden.bbs.entity.system.BaseSelectItem;
import com.yhgarden.bbs.model.response.BaseResponse;
import com.yhgarden.bbs.service.api.system.BaseSelectItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller("systemBaseSelectItemController")
@RequestMapping(value = {"/system/baseSelectItem","*/system/baseSelectItem"})
public class BaseSelectItemController {

    @Autowired
    private BaseSelectItemService selectItemService;

    /**
     * 创建或者修改实体信息
     * @param selectItem
     * @return
     */
    @RequestMapping(value = "/createOrUpdate", method = RequestMethod.POST,
            consumes = {"application/json"},
            produces = {"application/json"})
    @ResponseBody
    public BaseResponse createOrUpdate(@RequestBody BaseSelectItem selectItem) {
        BaseResponse res = selectItemService.createOrUpdate(selectItem);
        return res;
    }

    @RequestMapping(value = "/getById/{selectItemId}", method = RequestMethod.GET)
    @ResponseBody
    public BaseResponse getById(@PathVariable("selectItemId") String selectItemId) {
        BaseResponse res = selectItemService.getById(selectItemId);
        return res;
    }

    @RequestMapping(value = "/getByPid/{pid}", method = RequestMethod.GET)
    @ResponseBody
    public BaseResponse getByPid(@PathVariable("pid") String pid) {
        BaseResponse res = selectItemService.getByPid(pid);
        return res;
    }

    @RequestMapping(value = "/getByIdMoreDetail/{selectItemId}", method = RequestMethod.GET)
    @ResponseBody
    public BaseResponse getByIdMoreDetail(@PathVariable("selectItemId") String selectItemId) {
        BaseResponse res = selectItemService.getByIdMoreDetail(selectItemId);
        return res;
    }

    @RequestMapping(value = "/query", method = RequestMethod.POST,
            consumes = {"application/json"},
            produces = {"application/json"})
    @ResponseBody
    public BaseResponse query(@RequestBody BaseSelectItem selectItem) {
        BaseResponse res = selectItemService.query(selectItem);
        return res;
    }

    @RequestMapping(value = "/queryMoreDetail", method = RequestMethod.POST,
            consumes = {"application/json"},
            produces = {"application/json"})
    @ResponseBody
    public BaseResponse queryMoreDetail(@RequestBody BaseSelectItem selectItem) {
        BaseResponse res = selectItemService.queryMoreDetail(selectItem);
        return res;
    }

    @RequestMapping(value = "/delete/{selectItemId}", method = RequestMethod.POST)
    @ResponseBody
    public BaseResponse delete(@PathVariable("selectItemId") String selectItemId) {
        BaseResponse res = selectItemService.delete(selectItemId);
        return res;
    }

    @RequestMapping(value = "/batchDelete", method = RequestMethod.POST,
            consumes = {"application/json"},
            produces = {"application/json"})
    @ResponseBody
    public BaseResponse batchDelete(@RequestBody List<String> ids) {
        BaseResponse res = selectItemService.batchDelete(ids);
        return res;
    }
}
